package leetcode.weekly.week339;

//Solution1Test
public class Solution1 {

	public int findTheLongestBalancedSubstring(String s) {
		int ans = 0;
		for (int i = 0; i < s.length();) {
			int zero = 0, one = 0;
			while (i < s.length() && s.charAt(i) == '0') {
				zero++;
				i++;
			}
			while (i < s.length() && s.charAt(i) == '1') {
				one++;
				i++;
			}
			ans = Math.max(ans, Math.min(zero, one) << 1);
		}
		return ans;
	}
}
